<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.apache.commons.lang.StringUtils,java.util.*,java.util.Collection,com.hz.supermanage.bean.*"%>
<%@ page import="com.hz.framework.dao.CommonDao,com.hz.framework.util.DateUtil"%>
<%@ include file="../common/commonLabel.jsp"%>
<%@ include file="../common/commonJS.jsp"%>
<jsp:useBean id="dao" class="com.hz.supermanage.dao.OrganizationDao" />
<%
    String orgId = request.getParameter("orgId");
    String deptId = request.getParameter("deptId");
    String posId = request.getParameter("posId");
    String orgName="";
    String deptSelectHtml="";

    try {
        if (StringUtils.isBlank(orgId)) { //如果根单位为使用当前人
            orgId = "-1";
        }
        /**
         *   单位是必定会选择了的且不能修改的
         */
        Hzsysorganization dep = dao.queryNodeInfo(orgId);
        orgName = dep.getDepname();
        request.setAttribute("value", dao.getOrgDeptsSelect(orgId));
    }catch(Exception ex) {
        //throw new BusinessException("失败", ex);
    }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>增加新用户</title>
		<META http-equiv=Content-Type content=text/html;charset=UTF-8>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link href="${pageContext.request.contextPath}/parts/CSS/base.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/parts/CSS/main.css" rel="stylesheet" type="text/css" />
		<script
			src="${pageContext.request.contextPath}/parts/itemjs/supermanage/setup/Juice.js"></script>
		<script
			src="${pageContext.request.contextPath}/parts/itemjs/supermanage/setup/TreeMouseMenu.js"></script>
		<script
			src="${pageContext.request.contextPath}/parts/itemjs/supermanage/setup/Control.js"></script>
<script src="${pageContext.request.contextPath}/parts/itemjs/supermanage/setup/MessageMgr.js"></script>
<script type="text/javascript">
//部门选择改变，重新读取岗位的数据
function doDeptChange() {
  var d = event.srcElement;
  var v = d.value;
  loadDeptSelect(v);
}
function loadDeptSelect($v) {
	if($v!="")
	loadingSelectwherevt(__get("posId"),"HF02","and parentid = '"+$v+"'");//调用value和text不同的select筛选
}
function renderFinish() {
<%
if (StringUtils.isNotBlank(deptId)) {
%>
	__get("deptId").value = "<%=deptId%>";
	DWREngine.setAsync(false);
	loadDeptSelect("<%=deptId%>");
<%
if (StringUtils.isNotBlank(posId)) {
%>
	__get("posId").value = "<%=posId%>";
<%
}
%>
<%
}else {
%>
	var v = __get("deptId").value;
	if (!__isEmpty(v)) {
	  loadDeptSelect(v);
	}
<%
}
%>
}

function form1_check($domForm, $errorList) {
	__setServerTime('<%=DateUtil.longtime() %>');

	var domPos = __get("posId");
	if (domPos==null) {
		$errorList.add("用户必须有一个隶属岗位");
	}else {
	  if (__isEmpty(domPos.value)) {
	    $errorList.add("用户必须有一个隶属岗位");
	  }
	}
	var mail = __get("email").value;
	if(!isEmail(mail) && !__isEmpty(mail)) {
	    $errorList.add("邮件地址不合法，请确认");
	}
	if(document.all.logincheck.value == "false") {
	    $errorList.add("登录名已被占用，请确认");
	}
}
/**检查邮件地址合法性**/
function isEmail($m) {
    var pattern = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    if (pattern.test($m)) {
        return true;
    } else {
        return false;
    }
}
function doChecking(obj){
	ajax.checkOneData("hzsyspersonnel","loginid",obj.value,function(back){
		if(back){
			_alert("登录名已被占用");
			document.all.logincheck.value = "false";
			obj.focus();
		}else{
			document.all.logincheck.value = "true";
		}
	});
}
</script>
	</head>
	<body style="overflow: hidden; background-color: white;">
		<form method=post name=form1 action="xml/emp_add_action.jsp">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: white;">
				<tr>
					<td height="30" background="${pageContext.request.contextPath}/parts/images/tab_05.gif">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="12" height="30">
									<img src="${pageContext.request.contextPath}/parts/images/tab_03.gif"
										width="12" height="30" />
								</td>
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td width="46%" valign="middle">
												<table width="100%" border="0" cellspacing="0"
													cellpadding="0">
													<tr>
														<td width="5%">
															<div align="center">
																<img src="${pageContext.request.contextPath}/parts/images/tb.gif"
																	width="16" height="16" />
															</div>
														</td>
														<td width="95%" class="STYLE1">
															新增用户信息：
															<span id=domEmpFilterDesc style='color: red'></span>
														</td>
													</tr>
												</table>
											</td>
											<td width="54%" align="right">
												<div style="overflow: auto; width: 100%">
													<INPUT class="btn4" type="button" value="保  存"
														onclick="__post()" style='cursor: hand'>
													&nbsp;&nbsp;
													<INPUT class="btn4" type="button" value="关闭窗口"
														onclick="parent.__close()" style='cursor: hand'>
													&nbsp;&nbsp;
													<input type=hidden name="orgId" value="<%=orgId%>" />
													<input type=hidden name="userid" value="<%=userid%>" />
													<input type=hidden name="logincheck" value="" />
												</div>
											</td>
										</tr>
									</table>
								</td>
								<td width="16">
									<img
										src="${pageContext.request.contextPath}/parts/images/tab_07.gif"
										width="16" height="30" />
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0"
							cellpadding="0">
							<tr>
								<td width="8"
									background="${pageContext.request.contextPath}/parts/images/tab_12.gif">
									&nbsp;
								</td>
								<td align="center">
									&nbsp;&nbsp;
									<table width="95%" height="70%" cellpadding=2 align="center"
										class="MainBody_table">
										<COL ALIGN="right" width=17%>
										<COL ALIGN="left" width=33%>
										<COL ALIGN="right" width=17%>
										<COL ALIGN="left" width=33%>
										<tr height="23">
											<th >
												姓名：
											</th>
											<td>
												<input type=text class="ip_text notnull" name="personname"
													value='' tt.require=true maxlength=50>
											</td>
											<th>
												性别：
											</th>
											<td>
												<select name="sex" tt.selected="">
													<option value="男">
														男
													</option>
													<option value="女">
														女
													</option>
												</select>
											</td>

										</tr>
										<tr height="23">
											<th>
												登陆名：
											</th>
											<td>
												<input type=text class='ip_text notnull' tt.require=true
													name="loginid" value='' maxlength="20" onblur="doChecking(this)">
											</td>

											<th>
												密码：
											</th>
											<td>
												<input type=text class='ip_text notnull' tt.require=true
													name="password" value='' maxlength=20>
											</td>
										</tr>
										<tr height="23">
											<th>
												所属单位：
											</th>
											<td><%=orgName%>
												<input type="hidden" name="orgname" value="<%=orgName%>">
											</td>

											<th>
												所属部门：
											</th>
											<td>
												<select name='deptId' onchange="doDeptChange()"
													style="width: 120px">
													<option value="">
														请选择
													</option>
													<c:forEach items="${value}" var="rows">
														<option value="${rows.depid}">
															${rows.depname}
														</option>
													</c:forEach>
												</select>
											</td>
										</tr>
										<tr height="23">
											<th>
												隶属岗位：
											</th>
											<td id=DomPosSelect>
												<select name='posId' style="width: 120px">
													<option value="">
														请选择
													</option>
												</select>
											</td>
											<th>
												出生日期：
											</th>
											<td>
												<input type=text class='ip_text Wdate' name="birthday"
													onfocus="WdatePicker({dateFmt:'yyyy年MM月dd日',readOnly:true})">
											</td>
										</tr>
										<!-- 
<tr >
<td>民族：</td><td><input type=text class=ip_text name="folk" value='' maxlength=50></td>
<td>籍贯：</td><td><input type=text class=ip_text name="hometown" value='' maxlength=50></td>
</tr>
 -->
										<!-- 
<tr >
<td>最高学历：</td><td><input type=text class=ip_text name="mastdegree" value='' maxlength=50></td>
<td>其他证书：</td><td><input type=text class=ip_text name="certificate" value='' maxlength=50></td>
</tr>
 -->
										<!--
<tr>
<td>身份证号：</td><td><input type=text class=ip_text name="idcard" value='' maxlength=50 tt.checktype=IDCard ></td>
<td>健康情况：</td><td><input type=text class=ip_text name="health" value='' maxlength=50></td>
</tr>
 -->
										<tr height="23">
											<th>
												政治面貌：
											</th>
											<td>
												<input type=text class=ip_text name="genro" value=''
													maxlength=50>
											</td>
											<th>
												手机号码：
											</th>
											<td>
												<input type=text class='ip_text notnull' tt.require=true
													name="mobiletelephone" value='' maxlength=20>
											</td>
										</tr>

										<tr height="23">
											<th>
												婚姻情况：
											</th>
											<td>
												<select name="marriage" style="width: 120px" tt.selected="">
													<option value="未婚">
														未婚
													</option>
													<option value="已婚">
														已婚
													</option>
													<option value="离异">
														离异
													</option>
												</select>
											</td>
											<th>
												联系电话：
											</th>
											<td>
												<input type=text class='ip_text' name="telephone" value=''
													maxlength=50 tt.checktype=phone>
											</td>
										</tr>
										<tr height="23">
											<th>
												电子邮件：
											</th>
											<td colspan=3>
												<input type=text class='ip_text notnull' name="email"
													value='' maxlength=50 tt.require=true>
											</td>
										</tr>
										<tr height="23">
											<th>
												固定IP：
											</th>
											<td colspan=3>
												<input type=text class='ip_text' name="gid"
													value='' maxlength=50>
											</td>
										</tr>
										<tr height="23">
											<th>
												地址：
											</th>
											<td colspan=3>
												<input type=text class=ip_text name="address" value=''
													maxlength=150>
											</td>
										</tr>

										<tr height="23">
											<th>
												备注：
											</th>
											<td colspan=3>
												<textarea class=ip_textarea name="remark" maxlength=150
													style='height: 40px'></textarea>
											</td>
										</tr>
									</table>
									&nbsp;&nbsp;


								</td>
								<td width="8"
									background="${pageContext.request.contextPath}/parts/images/tab_15.gif">
									&nbsp;
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="35"
						background="${pageContext.request.contextPath}/parts/images/tab_19.gif">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="12" height="35">
									<img
										src="${pageContext.request.contextPath}/parts/images/tab_18.gif"
										width="12" height="35" />
								</td>
								<td>
									&nbsp;
								</td>
								<td width="16">
									<img
										src="${pageContext.request.contextPath}/parts/images/tab_20.gif"
										width="16" height="35" />
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>